from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.maximize_window()
driver.get("file:////Users/minyang/local/work/PycharmProjects/git/learn/week34/webautotest/page/multi.html")
sleep(3)
first_window = driver.current_window_handle #将首页句柄暂存
driver.find_element(By.LINK_TEXT,'register').click()
sleep(3)
all_window = driver.window_handles #获取所有句柄
for handle in all_window:
    if handle != first_window: #遍历找到不等于首页的
        driver.switch_to.window(handle)
        print('jumping!!')
sleep(1)
driver.find_element(By.ID,'kw').send_keys('fengluo')
sleep(2)
driver.find_element(By.ID,'su').click()
sleep(3)
driver.switch_to.window(first_window)
sleep(2)
el =driver.find_element(By.XPATH,"//*[@id='inputEmail']")
el.send_keys('jackson')
sleep(1)
el.clear()
sleep(1)
el.send_keys('fengluo')
sleep(1)
driver.find_element(By.XPATH,"//*[@id='inputPassword']").send_keys('123456')
sleep(1)
driver.find_element(By.XPATH,"/html/body/form/div[3]/div/button").click()
sleep(2)


# driver.quit()

